//
//  SearchResultCard.swift
//  Juejin App Demo
//
//  Created by 葛鹏 on 2021/8/22.
//

import SwiftUI

struct SearchResultCard: View {
    
    var searchResult: SearchResult
    
    var body: some View {
        VStack(alignment: .leading){
            
            HStack{
                Text(searchResult.title).font(.title2)
            }.padding(.bottom)
            
            HStack{
                Text(searchResult.author)
                Text(searchResult.date)
            }.padding(.bottom).foregroundColor(.gray)
            
            HStack{
                Text(searchResult.content).lineLimit(2)
            }.padding(.bottom)
            
            HStack(spacing: 20){
                HStack(spacing: 5){
                    Image(systemName: "hand.thumbsup")
                    Text(String(searchResult.like))
                }
                HStack(spacing: 5){
                    Image(systemName: "message")
                    Text("\(searchResult.comments)")
                }
                Spacer()
                HStack(spacing: 5){
                    ZStack{
                        Rectangle().foregroundColor(Color(red: 247/255, green: 247/255, blue: 247/255)).frame(width: 50,height: 30)
                        Text("Swift").foregroundColor(.gray)
                    }
                }
               
            }
            
        }.padding()
    }
}

struct SearchResultCard_Previews: PreviewProvider {
    static var previews: some View {
        SearchResultCard(searchResult: SearchResult(id: 1, title: "[译]想成为高级 iOS 开发者（Swift）？这些资料你不容错过", author: "iOS成长指北", date: "3月前", content: "当然，以我的拙见（更新时间](2019年10月10日）在很长一段时间以来，我的浏览器里有一个文件夹，里面有一些关于 iOS development + Swift 的文章和视频，这些文章和视频对我很有帮助。我敢肯定，大多数开发人员都有自己的库，里面有最好的东西。所以我决定分享我的信息", like: 56, comments: 4))
    }
}
